﻿@using NewsMvc.Models.Database
@{
	ViewData["Title"] = "NewWebsite";
	Layout = "/Views/Shared/_Layout.cshtml";
	var Articles = ViewData["Articles"] as List<Article>;//将从 ViewData 中获取的 "Articles" 数据转换为 List<Article> 类型的列表


}

<body>

	<!--动态变化区域-->
	<div id="main">
		<ul id="main_ul">
			@foreach (var item in Articles)//用了一个foreach循环；foreach(var 变量 in 遍历的集合)
			{
				<li>
					<a href="detail.html?id=@item.ArticleId">
						<img src=@item.picture alt="图片" />
						<p>@item.Title</p>
						<p>@item.Content</p>
						<p>发布时间:@item.PublishDate</p>
						<p>文章来源:@item.Source</p>
					</a>
				</li>
			}
		</ul>
	</div>

	
		<div class="paging">
			<ul class="pagination">
				<li><a href="@Url.Action("Index", "Home", new { pageid = 0 })">«</a></li>
				@for (var i = 0; i < ViewBag.TotalPages; i++)
				{
					<li>
						<a href="@Url.Action("Index", "Home", new { pageid = i })">@((i + 1).ToString())</a>
					</li>
				}
				<li><a href="@Url.Action("Index", "Home", new { pageid = ViewBag.TotalPages - 1 })">»</a></li>
			</ul>
		</div>
	




	<script>

	</script>
</body>
